home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / pctj8406.arc / MAINTAIN.PRG < prev    next >
Text File  |  1986-09-14  |  2KB  |  86 lines

  1. * maintain.prg
  2. *
  3. */this is a typical maintenance program used 
  4. */with a data file indexed on 7 + 1 keys. 
  5. */the eighth key is the social sec. no.  this 
  6. */program gives the user the facility to 
  7. */access a record by name and to review, update,
  8. */or delete the record.  the unique features are 
  9. */the means by which we keep our special key 
  10. */file (people1.dbf index soc) updated and 
  11. */also the technique by which we ignore the 
  12. */records marked for deletion.  the other 
  13. */seven indexes are the fields in the structure 
  14. */of people.dbf.
  15. SET talk OFF
  16. ERASE
  17. STORE '                    ' TO vname
  18. @ 10,00 SAY 'ENTER NAME YOU WANT ' GET vname
  19. READ
  20. CLEAR GETS
  21. USE people INDEX name,birth,tel,add,desc,sal,cat
  22. FIND &vname
  23. */this section checks for the existence of any
  24. */further records with this name and checks to
  25. */see if they are marked for deletion.
  26. IF # = 0
  27.     @ 12,00 SAY 'NAME DOES NOT EXIST. HIT RETURN' 
  28.     WAIT
  29.     RETURN
  30. ENDIF # = 0 
  31. STORE 1 TO t
  32. STORE 1 TO nn
  33. DO WHILE t = 1
  34.     DO WHILE * .AND. name = vname .AND. .not. eof
  35.         SKIP
  36.     ENDDO WHILE * .AND. name = vname .AND. .not. eof 
  37.     IF eof .OR. name # vname
  38.         IF nn = 1
  39.             @ 12,00 SAY 'NAME IS DELETED. HIT RETURN' 
  40.         ELSE
  41.             @ 12,00 SAY 'NO MORE RECORDS. HIT RETURN' 
  42.         ENDIF nn = 1 
  43.         WAIT
  44.         STORE 0 TO t
  45.         LOOP
  46.     ENDIF eof .OR. name # vname 
  47.     STORE 0 TO nn
  48.     ERASE
  49. */this section updates the record.
  50.     @ 03,00 SAY 'NAME' 
  51.     @ 04,00 SAY 'SOC. SEC. # ' GET socsec
  52.     @ 05,00 SAY 'DATE OF BIRTH ' GET birth
  53.     @ 06,00 SAY 'TELEPHONE ' GET tel
  54.     @ 07,00 SAY 'ADDRESS ' GET address
  55.     @ 08,00 SAY 'SALARY ' GET salary
  56.     @ 09,00 SAY 'DESCRIPTION ' GET descript
  57.     @ 10,00 SAY 'CATEGORY ' GET category 
  58.     @ 03,05 SAY name
  59.     READ
  60.     CLEAR GETS
  61. */this section illustrates the technique for 
  62. */updating the special key file (people1.dbf).
  63.     STORE # TO rec
  64.     STORE socsec TO vsoc
  65.     USE people1 INDEX soc
  66.     GOTO rec
  67.     REPLACE socsec WITH vsoc
  68. */this section deletes record if desired.
  69.     STORE ' ' TO yn
  70.     @ 20,00 SAY 'DELETE THIS RECORD ? ' GET yn
  71.     READ
  72.     CLEAR GETS
  73.     IF !(yn) = 'Y' 
  74.         DELETE
  75.         USE people
  76.         GOTO rec
  77.         DELETE
  78.     ENDIF 
  79.     USE people INDEX name,birth,tel,add,desc,sal,cat
  80.     GOTO rec
  81.     SKIP
  82. ENDDO WHILE t = 1 
  83. USE
  84. RELEASE ALL
  85. RETURN
  86.